package com.cskaoyan.converter;

import lombok.SneakyThrows;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 类<code>Doc</code>用于：TODO
 *
 * @author Acher
 * @version 1.0
 * @date 2021-10-16
 */
@Component// 注册组件即可使用
public class String2DateConverter implements Converter<String, Date> {
    @SneakyThrows
    @Override
    public Date convert(String source) {
        return new SimpleDateFormat("yyyy-MM-dd").parse(source);
    }

    @Override
    public <U> Converter<String, U> andThen(Converter<? super Date, ? extends U> after) {
        return null;
    }
}
